package com.zzptc.zzsgz.bdsjws.activities;

import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;

import com.zzptc.zzsgz.bdsjws.R;
import com.zzptc.zzsgz.bdsjws.activities.base.BaseActivity;
import com.zzptc.zzsgz.bdsjws.fragments.FirstFragment;
import com.zzptc.zzsgz.bdsjws.fragments.SecondFragment;

public class OneKey_SOS_Activity extends BaseActivity {

    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Toolbar toolbar= (Toolbar) findViewById(R.id.toolbar_one_key);
        setSupportActionBar(toolbar);
        ActionBar actionBar=getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    @Override
    public int getContentXML() {
        return R.layout.activity_one_key__sos_;
    }

    @Override
    public void initData() {

    }

    @Override
    public void initView() {
        imageView = (ImageView) findViewById(R.id.img_one_key_sos);
        getFragmentManager().beginTransaction().replace(R.id.framelayout_one_key,new FirstFragment()).addToBackStack("first").commit();
    }

    public void replace(){
        imageView.setVisibility(View.GONE);
        getFragmentManager().beginTransaction().replace(R.id.framelayout_one_key,new SecondFragment()).addToBackStack("second").commit();
    }

    @Override
    public void onBackPressed() {
        if(getFragmentManager().getBackStackEntryCount()>1){
            getFragmentManager().popBackStack();
            imageView.setVisibility(View.VISIBLE);
        }else {
            finish();
        }
    }
}
